From 870abdc5c7dbb3327a926529ea6e0048237b2036 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Tue, 7 Dec 2021 01:43:04 +0100
Subject: [PATCH] fix a bunch of fallthrough bullshit

this code conflicts with libc++ by defining fallthrough keyword
as macro and everything messes up
---
 include/compiler.h                           | 17 -----------------
 utils/cec-compliance/cec-test-audio.cpp      |  2 ++
 utils/cec-ctl/cec-ctl.cpp                    |  2 ++
 utils/cec-follower/cec-follower.cpp          |  2 ++
 utils/cec-follower/cec-processing.cpp        |  2 ++
 utils/cec-follower/cec-tuner.cpp             |  2 ++
 utils/common/v4l2-tpg-core.c                 |  2 ++
 utils/libcecutil/cec-log.cpp                 |  2 ++
 utils/qv4l2/v4l2-tpg-core.c                  |  2 ++
 utils/qvidcap/v4l2-tpg-core.c                |  2 ++
 utils/v4l2-compliance/v4l2-test-colors.cpp   |  2 ++
 utils/v4l2-compliance/v4l2-test-controls.cpp |  2 ++
 utils/v4l2-compliance/v4l2-test-formats.cpp  |  2 ++
 utils/v4l2-ctl/v4l2-ctl-edid.cpp             |  2 ++
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp        |  2 ++
 utils/v4l2-ctl/v4l2-ctl-vbi.cpp              |  2 ++
 utils/v4l2-ctl/v4l2-tpg-core.c               |  2 ++
 17 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/include/compiler.h b/include/compiler.h
index 5ad54f4..e69de29 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -1,17 +0,0 @@
-#ifdef _LIBCPP_VERSION
-#define fallthrough _LIBCPP_FALLTHROUGH()
-#else
-
-#if __cplusplus >= 201103L
-
-#ifdef __clang__
-#define fallthrough [[clang::fallthrough]]
-#else
-#define fallthrough [[gnu::fallthrough]]
-#endif // __clang__
-
-#else
-#define fallthrough ((void)0)
-
-#endif // __cplusplus
-#endif // _LIBCPP_VERSION
diff --git a/utils/cec-compliance/cec-test-audio.cpp b/utils/cec-compliance/cec-test-audio.cpp
index 611f600..7d9d042 100644
--- a/utils/cec-compliance/cec-test-audio.cpp
+++ b/utils/cec-compliance/cec-test-audio.cpp
@@ -13,6 +13,8 @@
 #include "cec-compliance.h"
 #include "compiler.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static std::string audio_format_code2s(__u8 format_code)
 {
 	switch (format_code) {
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 4bed81a..0cd1f02 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -34,6 +34,8 @@
 #include "cec-ctl.h"
 #include "compiler.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static struct timespec start_monotonic;
 static struct timeval start_timeofday;
 static bool ignore_la[16];
diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp
index 0adf6ce..30e6386 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -14,6 +14,8 @@
 #include "cec-follower.h"
 #include "compiler.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 /* Short option list
 
    Please keep in alphabetical order.
diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp
index 661cbf4..a51b621 100644
--- a/utils/cec-follower/cec-processing.cpp
+++ b/utils/cec-follower/cec-processing.cpp
@@ -13,6 +13,8 @@
 #include "cec-follower.h"
 #include "compiler.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 #define VOLUME_MAX 0x64
 #define VOLUME_MIN 0
 
diff --git a/utils/cec-follower/cec-tuner.cpp b/utils/cec-follower/cec-tuner.cpp
index a2cb6ca..ae7fd6e 100644
--- a/utils/cec-follower/cec-tuner.cpp
+++ b/utils/cec-follower/cec-tuner.cpp
@@ -11,6 +11,8 @@
 #include "cec-follower.h"
 #include "compiler.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 #define NUM_ANALOG_FREQS 3
 #define NUM_DIGITAL_CHANS 3
 #define TOT_ANALOG_FREQS analog_freqs_khz[0][0].size()
diff --git a/utils/common/v4l2-tpg-core.c b/utils/common/v4l2-tpg-core.c
index f0090ed..ad43426 100644
--- a/utils/common/v4l2-tpg-core.c
+++ b/utils/common/v4l2-tpg-core.c
@@ -11,6 +11,8 @@
 #include "compiler.h"
 #include "v4l2-tpg-colors.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 /* Must remain in sync with enum tpg_pattern */
 const char * const tpg_pattern_strings[] = {
 	"75% Colorbar",
diff --git a/utils/libcecutil/cec-log.cpp b/utils/libcecutil/cec-log.cpp
index 0ee63de..3b176e2 100644
--- a/utils/libcecutil/cec-log.cpp
+++ b/utils/libcecutil/cec-log.cpp
@@ -14,6 +14,8 @@
 #include "cec-log.h"
 #include "compiler.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static const struct cec_arg arg_u8 = {
 	CEC_ARG_TYPE_U8,
 };
diff --git a/utils/qv4l2/v4l2-tpg-core.c b/utils/qv4l2/v4l2-tpg-core.c
index f0090ed..ad43426 100644
--- a/utils/qv4l2/v4l2-tpg-core.c
+++ b/utils/qv4l2/v4l2-tpg-core.c
@@ -11,6 +11,8 @@
 #include "compiler.h"
 #include "v4l2-tpg-colors.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 /* Must remain in sync with enum tpg_pattern */
 const char * const tpg_pattern_strings[] = {
 	"75% Colorbar",
diff --git a/utils/qvidcap/v4l2-tpg-core.c b/utils/qvidcap/v4l2-tpg-core.c
index f0090ed..ad43426 100644
--- a/utils/qvidcap/v4l2-tpg-core.c
+++ b/utils/qvidcap/v4l2-tpg-core.c
@@ -11,6 +11,8 @@
 #include "compiler.h"
 #include "v4l2-tpg-colors.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 /* Must remain in sync with enum tpg_pattern */
 const char * const tpg_pattern_strings[] = {
 	"75% Colorbar",
diff --git a/utils/v4l2-compliance/v4l2-test-colors.cpp b/utils/v4l2-compliance/v4l2-test-colors.cpp
index 887b2fd..42ddb9a 100644
--- a/utils/v4l2-compliance/v4l2-test-colors.cpp
+++ b/utils/v4l2-compliance/v4l2-test-colors.cpp
@@ -23,6 +23,8 @@
 #include "compiler.h"
 #include "v4l2-compliance.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static void setupPlanes(const cv4l_fmt &fmt, __u8 *planes[3])
 {
 	if (fmt.g_num_planes() > 1)
diff --git a/utils/v4l2-compliance/v4l2-test-controls.cpp b/utils/v4l2-compliance/v4l2-test-controls.cpp
index 22e8dec..e456cc3 100644
--- a/utils/v4l2-compliance/v4l2-test-controls.cpp
+++ b/utils/v4l2-compliance/v4l2-test-controls.cpp
@@ -29,6 +29,8 @@
 #include "compiler.h"
 #include "v4l2-compliance.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static int checkQCtrl(struct node *node, struct test_query_ext_ctrl &qctrl)
 {
 	struct v4l2_querymenu qmenu;
diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 3761b1f..de04136 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -27,6 +27,8 @@
 #include "compiler.h"
 #include "v4l2-compliance.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static constexpr __u32 buftype2cap[] = {
 	0,
 	V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_M2M,
diff --git a/utils/v4l2-ctl/v4l2-ctl-edid.cpp b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
index c3a4a28..e7a5406 100644
--- a/utils/v4l2-ctl/v4l2-ctl-edid.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
@@ -6,6 +6,8 @@
 #include "compiler.h"
 #include "v4l2-ctl.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 /*
  * The 24-bit IEEE Registration Identifier for the HDMI-LLC Vendor
  * Specific Data Block.
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 7e24e0e..732412c 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -14,6 +14,8 @@ extern "C" {
 #include "v4l2-tpg.h"
 }
 
+#define fallthrough [[clang::fallthrough]]
+
 static unsigned stream_count;
 static unsigned stream_skip;
 static __u32 memory = V4L2_MEMORY_MMAP;
diff --git a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
index dc7b428..4a49d52 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp
@@ -3,6 +3,8 @@
 #include "compiler.h"
 #include "v4l2-ctl.h"
 
+#define fallthrough [[clang::fallthrough]]
+
 static struct v4l2_format sliced_fmt;	  /* set_format/get_format for sliced VBI */
 static struct v4l2_format sliced_fmt_out; /* set_format/get_format for sliced VBI output */
 static struct v4l2_format raw_fmt;	  /* set_format/get_format for VBI */
diff --git a/utils/v4l2-ctl/v4l2-tpg-core.c b/utils/v4l2-ctl/v4l2-tpg-core.c
index f0090ed..800032a 100644
--- a/utils/v4l2-ctl/v4l2-tpg-core.c
+++ b/utils/v4l2-ctl/v4l2-tpg-core.c
@@ -11,6 +11,8 @@
 #include "compiler.h"
 #include "v4l2-tpg-colors.h"
 
+#define fallthrough ((void)0)
+
 /* Must remain in sync with enum tpg_pattern */
 const char * const tpg_pattern_strings[] = {
 	"75% Colorbar",
-- 
2.34.1

